#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int numIdenticalPairs(vector<int>& nums) {
        map<int, int> m1;
        for (auto& e : nums)
        {
            m1[e]++;
        }

        int Good = 0;
        for (auto& e : m1)
        {
            Good += e.second * ((e.second - 1) / 2);
            cout << Good << endl;
            if ((e.second - 1) % 2)
            {
                Good += e.second / 2;
            }
        }

        return Good;
    }
};